package com.haidechizi.designpattern.strategy.simple;

/**
 * @author haidechizi
 */
public class CalculateFactory {

    /**
     * 获取具体的计算方式
     *
     * @param operate
     * @return
     */
    public static Calculate getInstance(String operate) {
        if ("+".equals(operate)) {
            return new AddCalculate();
        } else if ("-".equals(operate)) {
            return new SubtractCalculate();
        } else if ("*".equals(operate)) {
            return new MultiplyCalculate();
        }
        throw new UnsupportedOperationException("不支持当前操作");
    }
}
